<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ page import="com.itheima.domain.Book" import="java.util.List"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>查找图书</title>
</head>
<body>
	<center>
		<%if(request.getSession().getAttribute("user") != null) { %>
		<h2>请输入信息查找图书</h2>

		<a id="back" href="index.jsp">返回主页</a>
		<div id="idfind">
			<form action="" method="post">
				请输入您要查找的编号: <input type="text" name="id"><br>

				<input type="submit" value="查找">
				<a href="findbookServlet">返回</a>
			</form>
		</div>
		<div id="namefind">
			<form action="/search/book" method="post">
				请输入您要查找的书名: <input type="text" name="bookName"></br>
				请输入您要查找的作者: <input type="text" name="author"></br>
				请输入您要查找的最低价格: <input type="text" name="minPrice"></br>
				请输入您要查找的最高价格: <input type="text" name="maxPrice"></br>
				<input type="submit" value="提交">
				<a href="findbookServlet">清空</a>
			</form>
		</div>


		<div id="show">
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<table class="table">
							<thead>
								<tr>
									<th>编号</th>
									<th>书名</th>
									<th>作者</th>
									<th>价格</th>
									<th>预览</th>
									<th>下载</th>
								</tr>
							</thead>
							<%
							if (request.getAttribute("bookList") != null){
								List<Book> booklist = (List<Book>)request.getAttribute("bookList");%>

								<tbody>
									<% for(Book book:booklist){ %>
										<tr class="success">
											<td>
												<%=book.getId() %>
											</td>
											<td>
												<%=book.getBookName() %>
											</td>
											<td>
												<%=book.getAuthor() %>
											</td>
											<td>
												<%=book.getPrice() %>
											</td>
											<td>
												<button>预览</button>
											</td>
											<td>
												<button>下载</button>
											</td>
										</tr>
									<%} %>
								</tbody>
<%							}%>
						</table>
					</div>
				</div>
			</div>
		</div>
		<%} else {%>
		<h1>请登录后再访问此页面</h1>
		<a href="LoginOut"><i>返回登陆</i></a>
		<%} %>
		<font color="red" size="2"> ${msg }</font>
	</center>
	<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/findbook.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>